home *** CD-ROM | disk | FTP | other *** search
- /* Data and prototypes that are shared by both client and server */
-
- #include <libraries/diskfont.h>
-
- #define UNLESS(x) if(!(x))
-
- #define AMITRACK_TIMEOUT_MINUTES 5
-
- /* Possible Request bits for the first data byte of the UDP packets */
- #define REQ_COMMENT 0x01 /* "My comment is now this string:" */
- #define REQ_BYE 0x02 /* "I'm quitting, remove me immediately" */
-
- /* Used internally by the event loops */
- #define CODE_UDP_SOCKET 0x0001 /* "You've got a UDP packet ready to read" */
- #define CODE_TCP_SOCKET 0x0002 /* "You've got a TCP connection ready" */
- #define CODE_TIMER_EXPIRED 0x0004 /* "The timer expired." */
- #define CODE_REFRESH 0x0008 /* "Please redraw the client list." */
- #define CODE_WINDOW_EVENT 0x0010 /* "Check for IDCMP stuff." */
- #define CODE_PING 0x0020 /* "Send a ping, please." */
- #define CODE_RECONNECT 0x0040 /* "Possibly reconnect to another server/port" */
- #define CODE_ICONIFY 0x0080 /* "Iconify, please." */
- #define CODE_MSGPORT 0x0100 /* "A message is at your message port." */
-
- /* Since TCP and UDP have separate port domains, I can use the same port numbers
- for the UDP and TCP ports */
- #define SERVER_UDP_PORT 18945 /* UDP port for the server process */
- #define SERVER_TCP_PORT 18945 /* TCP port for the server process */
-
- struct ClientList {
- struct List list;
- int nListLength;
- };
-
- struct Client {
- struct Node node;
- time_t tDateStamp;
- char * hostname;
- char * comment;
- ULONG ulIPAddress;
- };
-
- struct TimerStuff {
- struct MsgPort * TimerMP;
- struct timerequest * TimerIO;
- BOOL BDevOpen;
- };
-
- struct SocketStuff {
- LONG fd; /* socket # */
- LONG lSocketType; /* either SOCK_STREAM or SOCK_DGRAM, please */
- struct sockaddr_in saAddr;
- };
-
-
- struct WindowStuff {
- struct Screen * screen; /* Pointer to screen we're on */
- struct Window * win; /* Pointer to Intuition window structure */
- struct TextAttr font; /* Gadget rendering font */
- struct TextFont * fontdata; /* The font's bits */
- struct TextAttr fixedfont; /* ListView rendering font */
- struct TextFont * fixedfontdata;/* This font's bits */
- struct List * DisplayList; /* Our list of strings for the ListView */
- void * vi; /* visual info for gadgets */
- struct Gadget * glist; /* list of all our gadgets */
- struct Gadget * ListGadget; /* ListView of all logins */
- struct Gadget * PingButton; /* Manual ping */
- struct Gadget * UpdateButton; /* Manual update */
- struct Gadget * ServerString; /* Server display/chooser string */
- struct Gadget * PortString; /* Port display/chooser string */
- struct Gadget * CommentString; /* Comment display/chooser string */
- struct Gadget * UpdateIntString;/* Choose list refresh interval */
- struct Gadget * PingIntString; /* Choose ping interval */
- };
-
-
-
-
-
-
- /* Shared functions */
- struct ClientList * SetupClientList(struct ClientList * clientList);
- struct TimerStuff * SetupTimer(struct TimerStuff * ts);
- struct SocketStuff * SetupSocket(struct SocketStuff * ss, int nPort, LONG lSocketType);
-
- ULONG TrackWait(struct SocketStuff * TCPStuff, struct SocketStuff * UDPStuff, struct TimerStuff * Timer, struct WindowStuff * Window, struct MsgPort * msgport);
-
- struct Client * NewClient(ULONG ulIPAddress, char * szHostName, char * szOptComment);
- void FreeClient(struct Client * client);
-
- void ReplaceAllocedString(char ** szOldString, char * szNewString);
- void SetTimer(struct TimerStuff * ts, int nSecs, int nMicros);
- void TrackExit(char * szMessage, int nCode);
-
- struct Client * GetClient(struct ClientList * ClientList, ULONG ulIPAddr, char * szHostName, char * szOptComment);
- BOOL RemoveClient(struct ClientList * ClientList, char * szHostName);
- BOOL FillInfos(struct SocketStuff * sSocket, char **pSetName, ULONG * ulIPAddress, char **pSetComment);
- void PrintClientList(struct ClientList *);
- void ClearTrackScreen(void);
-
- struct ClientList * GetTrackList(char * szHostName, int nPortNum);
-
- int MakeReq(char *sTitle, char *sText, char *sGadgets);
-
- char * PastSpaces(char * pcString);
- char * RemoveUnprintableChars(char * pcString);
- char * RemoveTrailingSpaces(char * pcString);
- char * ToLower(char * pcString);